#ifndef TCPCLIENT_H
#define TCPCLIENT_H

#include <QObject>
#include <QTcpSocket>
#include <QMap>

class TcpClient : public QObject
{
    Q_OBJECT
public:
    explicit TcpClient(QObject *parent = nullptr);

    void openAllPort();
    void sendData(const int& clinetPort, const QByteArray& data);

signals:
    void dataReceivedFromClient(int logicalClientPort, const QByteArray &data); // logicalClientPort is the key from tcpClients map
    void sendDataFrom(int clientPort, const QByteArray& data);
public slots:
    void dealMsg();
private:
    QMap<int, QTcpSocket*> tcpClients;
};

#endif // TCPCLIENT_H
